package com.ymttest.database.sqlwapper;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import com.ymt.core.tool.FormatUtil;
import com.ymt.database.SqlManager;
import com.ymttest.database.model.*;
import com.ymttest.database.model.livetv.LiveModel;
import com.ymttest.database.model.livetv.LiveProductDot;
import com.ymttest.database.model.livetv.Model;
import com.ymttest.database.model.livetv.ProductVideo;
import com.ymttest.database.model.livetv.ProductVideoExplain;
import com.ymttest.utils.YMTDateUtil;

import ch.ethz.ssh2.log.Logger;

public class LiveRoomWapper {
	SqlManager manage;

	public LiveRoomWapper() {
		manage = new SqlManager("ymtlivetv");
	}
	//selectLiveSellerTopByExample
	/**
	 * 查询直播排行
	 * @param LiveActivityProductId
	 * @return
	 */
	public LiveSellerTop selectLiveSellerTopByExample(Integer sellerid) {
		LiveSellerTopExample LiveSellerTopExample=new LiveSellerTopExample();
		LiveSellerTopExample.createCriteria().andUserIdEqualTo(sellerid);
		List<LiveSellerTop> liveroom = (List<LiveSellerTop>) manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectLiveSellerTopByExample", LiveSellerTopExample);
		manage.commit();
		return liveroom.get(0);
	}
	//selectProductvideoExplain
	/**
	 * 查询x希望求讲解商品
	 * @param pid
	 * @return
	 */
	public List<ProductVideoExplain> selectProductvideoExplains(String pid) {
		Map m=new HashMap<>();
		m.put("pid", pid);
		List<ProductVideoExplain> liveroom = (List<ProductVideoExplain>) manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectProductvideoExplain", m);
		manage.commit();
		if(liveroom!=null&&liveroom.size()>0) {
			return liveroom;
		}
		return null;
	}
	
	/**
	 * 查询x希望求讲解商品
	 * @param pid
	 * @return
	 */
	public ProductVideoExplain selectProductvideoExplain(String pid) {
		Map m=new HashMap<>();
		m.put("pid", pid);
		List<ProductVideoExplain> liveroom = (List<ProductVideoExplain>) manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectProductvideoExplain", m);
		manage.commit();
		if(liveroom!=null&&liveroom.size()>0) {
			return liveroom.get(0);
		}
		return null;
	}
	/**
	 * 查询求讲解商品视频录制数据
	 * @param pid
	 * @return
	 */
	public ProductVideo selectProductvideo(String pid) {
		Map m=new HashMap<>();
		m.put("pid", pid);
		List<ProductVideo> liveroom = (List<ProductVideo>) manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectProductvideo", m);
		manage.commit();
		if(liveroom!=null&&liveroom.size()>0) {
			return liveroom.get(0);
		}
		return null;
	}
	/**
	 * 查询直播订阅
	 * @param LiveActivityProductId
	 * @return
	 */
	public LiveActivitySubscribe selectLiveActivitySubscribeByExample(Integer LiveActivityProductId) {
		LiveActivitySubscribeExample LiveActivitySubscribeExample=new LiveActivitySubscribeExample();
		LiveActivitySubscribeExample.createCriteria().andLiveActivityProductIdEqualTo(LiveActivityProductId);
		List<LiveActivitySubscribe> liveroom = (List<LiveActivitySubscribe>) manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectLiveActivitySubscribeByExample", LiveActivitySubscribeExample);
		manage.commit();
		return liveroom.get(0);
	}
	/**
	 * 根据liveid查询liveromm信息
	 * 
	 * @param id
	 * @return
	 */
	public LiveRoom selectLiveRoomById(Integer id) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("id", id);
		List<LiveRoom> liveroom = (List<LiveRoom>) manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectLiveRoomById", params);
		manage.commit();
		return liveroom.get(0);
	}
	/**查询UserOnlineStatus
	 * @param uid
	 * @return
	 */
	public UserOnlineStatus selectUserOnlinestatus(String uid) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("uid", uid);
		List<UserOnlineStatus> liveroom = (List<UserOnlineStatus>) manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectUserOnlinestatus", params);
		manage.commit();
		return liveroom.get(0);
	}
	public UserOnlineStatus selectGlobalUserOnlineStatus(String uid) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("uid", uid);
		List<UserOnlineStatus> liveroom = (List<UserOnlineStatus>) manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectGlobalUserOnlineStatus", params);
		manage.commit();
		return liveroom.get(0);
	}

	/**
	 * 查询10条微信直播小铺liveroom数据
	 * @return
	 */
	public List<LiveRoom> selectWxLives() {
		List<LiveRoom> liveroom = (List<LiveRoom>) manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectWxLives", null);
		manage.commit();
		return liveroom;
	}
	public Map selectLastLiveOnlineStatById(Integer liveid) {
		List<Map> liveroom = (List<Map>) manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectLastLiveOnlineStatById", liveid);
		manage.commit();
		if (liveroom == null || liveroom.isEmpty()) {
			return null;
		}
		return liveroom.get(0);
	}

	/**
	 * 查询可以开始播放的liveroom 状态已结束的被剔除
	 * 
	 * @param userid
	 * @return
	 */
	public List<LiveRoom> selectRunningLiveRoomByUserid(Integer userid) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("userid", userid);
		List<LiveRoom> liveroom = (List<LiveRoom>) manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectRunningLiveRoomByUserid", params);
		manage.commit();
		return liveroom;
	}

	/**
	 * 最后一个加入的liveroom
	 * 
	 * @return
	 */
	public LiveRoom selectLastLiveRoom() {
		List<LiveRoom> liveroom = (List<LiveRoom>) manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectLastLiveRoom", null);
		manage.commit();
		return liveroom.get(0);
	}

	/**
	 * 查询商品信息
	 * 
	 * @param liveid
	 * @return
	 */
	public List<Map> selectLiveproductByLiveid(Integer liveid) {
		Map m = new HashMap<>();
		m.put("liveid", liveid);
		List<Map> liveroom = (List<Map>) manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectLiveproductByLiveid", m);
		manage.commit();
		return liveroom;
	}

	/**
	 * 查询置顶商品
	 * 
	 * @param liveid
	 * @return
	 */
	public List<Map> selectTopLiveproductByLiveid(Integer liveid) {
		Map m = new HashMap<>();
		m.put("liveid", liveid);
		List<Map> liveroom = (List<Map>) manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectTopLiveproductByLiveid", m);
		manage.commit();
		return liveroom;
	}

	/**
	 * 查询直播间在线的人
	 * 
	 * @param liveid
	 * @param uid
	 * @return
	 */
	public List<Map> selectLivemember(Integer liveid, Integer uid) {
		Map m = new HashMap<>();
		m.put("liveid", liveid);
		m.put("uid", uid);
		List<Map> liveroom = (List<Map>) manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectLivemember", m);
		manage.commit();
		return liveroom;
	}
	
	/**
	 * 查找可显示的直播 预告中， 直播中， 已结束
	 * @param uid
	 * @return
	 */
	public List<Map> selectDisPlayLiveroomByUId(Integer uid) {
		List<Map> liveroom = (List<Map>) manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectDisPlayLiveroomByUId", uid);
		manage.commit();
		return liveroom;
	}
	/**
	 * 按uid查询足迹
	 * @param uid
	 * @return
	 */
	public List<Map> selectLivefootprintByUid(Integer uid) {
		List<Map> liveroom = (List<Map>) manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectLivefootprintByUid", uid);
		manage.commit();
		return liveroom;
	}
	/**
	 * 查询最近的足迹
	 * @return
	 */
	public List<Map> selectLivefootprint100() {
		List<Map> liveroom = (List<Map>) manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectLivefootprint100", null);
		manage.commit();
		return liveroom;
	}
	/**
	 * 根据直播号商品id查询商品
	 * 
	 * @param liveid
	 * @param productid
	 * @return [{ProductNo=0, Status=1, IsTop=false, Action=0, UserId=2254514,
	 *         CreateTime=2017-10-25 15:44:12.0, LiveId=299,
	 *         UpdateTime=2017-10-25 15:44:12.0, LiveProductId=350,
	 *         ProductId=da541da7-eacf-4fd1-bf86-ff30e120427c, SortNo=999000}]
	 */
	public List<Map> selectLiveproductByIdAndPid(Integer liveid, String productid) {
		Map m = new HashMap<>();
		m.put("liveid", liveid);
		m.put("productid", productid);
		List<Map> liveroom = (List<Map>) manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectLiveproductByIdAndPid", m);
		manage.commit();
		return liveroom;
	}

	/**
	 * 根据liveid查询在线人数比心数换算记录
	 * 
	 * @param id
	 * @return
	 */
	public Map selectLiveRoomStatById(Integer id) {
		Map m = new HashMap<>();
		m.put("id", id);
		List<Map> liveroomstatus = (List<Map>) manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectLiveRoomStatById", m);
		manage.commit();
		if (liveroomstatus != null && liveroomstatus.size() > 0) {
			return liveroomstatus.get(0);
		} else {
			return null;
		}
	}

	/**
	 * 删除观众观看记录
	 * 
	 * @param liveid
	 * @param uid
	 * @return
	 */
	public int deleteLivemember(Integer liveid, Integer uid) {
		Map m = new HashMap<>();
		m.put("liveid", liveid);
		m.put("uid", uid);
		int i = manage.delete("com.ymttest.database.mapping.LiveRoomMapper.deleteLivemember", m);
		manage.commit();
		return i;
	}

	/**
	 * 通过productid更新商品信息
	 * 
	 * @param productid
	 *            商品id
	 * @param istop
	 *            是否置顶
	 * @param status
	 *            状态 且 status是1（在售）0是不可售
	 * @param action
	 *            是0（未删除） -1是删除
	 * @return
	 */
	public int updateLiveProductStatusById(Integer LiveProductId, Integer istop, Integer status, Integer action) {
		Map m = new HashMap<>();
		m.put("LiveProductId", LiveProductId);
		m.put("istop", istop);
		m.put("status", status);
		m.put("action", action);
		int i = manage.update("com.ymttest.database.mapping.LiveRoomMapper.updateLiveProductStatusById", m);
		manage.commit();
		return i;
	}

	/**
	 * 更新直播开始结束时间
	 * 
	 * @param starttime
	 *            格式 2017-10-24 16:50:13
	 * @param endtime
	 *            格式 2017-10-24 16:50:13
	 * @param id
	 *            liveid
	 * @return
	 */
	public int updateLiveRoomTime(String starttime, String endtime, String updatetime,Integer id) {
		Map m = new HashMap<>();
		m.put("id", id);
		m.put("starttime", starttime);
		m.put("endtime", endtime);
		m.put("updatetime", updatetime);
		int i = manage.update("com.ymttest.database.mapping.LiveRoomMapper.updateLiveRoomTime", m);
		if (i == 1) {
			manage.commit();
		} else {
			manage.rollback();
		}
		return i;
	}
//	updateLiveRoomGroupIdToNull
	/**
	 * 设置live的groupid为null
	 * @param id liveid
	 * @return
	 */
	public int updateLiveRoomGroupIdToNull(Integer id) {
		Map m = new HashMap<>();
		m.put("id", id);
		int i = manage.update("com.ymttest.database.mapping.LiveRoomMapper.updateLiveRoomGroupIdToNull", m);
		if (i == 1) {
			manage.commit();
		} else {
			manage.rollback();
		}
		return i;
	}
	public int updateLiveRoomEndTimeAndUpdateTime(String endTime, String updateTime, Integer id) {
		Map m = new HashMap<>();
		m.put("id", id);
		m.put("endTime", endTime);
		m.put("updateTime", updateTime);
		int i = manage.update("com.ymttest.database.mapping.LiveRoomMapper.updateLiveRoomEndTimeAndUpdateTime", m);
		if (i == 1) {
			manage.commit();
		} else {
			manage.rollback();
		}
		return i;
	}

	/**
	 * 更新推流状态？
	 * 
	 * @param liveid
	 * @param livestatus
	 * @return
	 */
	public int updateLiveRoomPushStatus(Integer liveid, Integer livestatus) {
		Map m = new HashMap<>();
		m.put("liveid", liveid);
		m.put("livestatus", livestatus);
		int i = manage.update("com.ymttest.database.mapping.LiveRoomMapper.updateLiveRoomPushStatus", m);
		manage.commit();
		return i;
	}

	/**
	 * 查询直播数量
	 * 
	 * @return
	 */
	public Long selectCountLiveroom(Integer uid,Integer livetype) {
		Map param = new HashMap<>();
		param.put("uid", uid);
		param.put("livetype", livetype);
		Long m = (Long) manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectCountLiveroom", param).get(0);
		manage.commit();
		return m;
	}

	/**
	 * 直播订阅
	 * 
	 * @return
	 */
	public List<Map> selectLiveSubscribeById(Integer liveid, Integer userid) throws InterruptedException {
		Map m = new HashMap<>();
		m.put("liveid", liveid);
		m.put("userid", userid);
		List<Map> LiveSubscribeMap = manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectLiveSubscribeById", m);
		manage.commit();
		return LiveSubscribeMap;
	}

	public List<Map> selectLivevisitorById(String deviceid) throws InterruptedException {
		Map m = new HashMap<>();
		m.put("deviceid", deviceid);
		List<Map> LiveSubscribeMap = manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectLivevisitorById", m);
		manage.commit();
		return LiveSubscribeMap;
	}

	/**
	 * @param status 直播状态
	 * @param livetype 0 码头直播 1直播小铺
	 * @return
	 * @throws InterruptedException
	 */
	public Long selectCountLiveroomByStatus(Integer status,Integer livetype) throws InterruptedException {
		Map param = new HashMap<>();
		param.put("status", status);
		param.put("livetype", livetype);
		Long count = (Long) manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectCountLiveroomByStatus", param).get(0);
		manage.commit();
		return count;
	}

	/**
	 * @param liveid
	 * @param action -1 删除
	 * @return
	 */
	public int updateLiveRoomAction(Integer liveid, Integer action) {
		Map m = new HashMap<>();
		m.put("liveid", liveid);
		m.put("action", action);
		int i = manage.update("com.ymttest.database.mapping.LiveRoomMapper.updateLiveRoomAction", m);
		manage.commit();
		return i;
	}

	public Map selectMessagetaskByMsgtime(String msgtime) throws InterruptedException {
		Map m = new HashMap<>();
		m.put("msgtime", msgtime);
		List<Map> messagetaske = manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectMessagetaskByMsgtime", m);
		manage.commit();
		if(messagetaske!=null&&!messagetaske.isEmpty()){
			return messagetaske.get(0);
		}else{
			return null;
		}
	}
	public Integer selectLivedebugCountById(String id) throws InterruptedException {
		Map m = new HashMap<>();
		m.put("id", id);
		Integer count = (Integer) manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectLivedebugCountById", m).get(0);
		manage.commit();
		return count;
	}
	public Map selectLivereplayById(String liveid) throws InterruptedException {
		Map m = new HashMap<>();
		m.put("liveid", liveid);
		List<Map> messagetaske = manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectLivereplayById", m);
		manage.commit();
		if(messagetaske!=null&&!messagetaske.isEmpty()){
			return messagetaske.get(0);
		}else{
			return null;
		}
	}
	/**
	 * 查询秒杀
	 * @param id
	 * @return
	 * @throws InterruptedException
	 */
	public List<Map> querySecKillProductList() throws InterruptedException {
		List<Map> query = manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.querySecKillProductList", null);
		manage.commit();
		return query;
	}
	/**
	 * 查询热销
	 * @param id
	 * @return
	 * @throws InterruptedException
	 */
	public List<Map> queryHotSaleProducts() throws InterruptedException {
		List<Map> query = manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.queryHotSaleProducts", null);
		manage.commit();
		return query;
	}
	
	/**
	 * LiveActivityId 查询
	 * @param lid
	 * @return
	 * @throws InterruptedException
	 */
	public LiveActivity selectLiveactivityById(Integer lid) throws InterruptedException {
		Map m = new HashMap<>();
		m.put("lid", lid);
		List<LiveActivity> messagetaske = manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectLiveactivityById", m);
		manage.commit();
		if(messagetaske!=null&&!messagetaske.isEmpty()){
			return messagetaske.get(0);
		}else{
			return null;
		}
	}
	/**
	 * liveid查询全部
	 * @param lid
	 * @return
	 * @throws InterruptedException
	 */
	public List<LiveActivity> selectLiveactivityByLiveId(Integer lid) throws InterruptedException {
		Map m = new HashMap<>();
		m.put("lid", lid);
		List<LiveActivity> messagetaske = manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectLiveactivityByLiveId", m);
		manage.commit();
		return messagetaske;
	}
	//selectLiveactivityByProduct
	public List<LiveActivityProduct> selectLiveactivityByProduct(String pid) throws InterruptedException {
		Map m = new HashMap<>();
		m.put("pid", pid);
		List<LiveActivityProduct> messagetaske = manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectLiveactivityByProduct", m);
		manage.commit();
		return messagetaske;
	}
	/**
	 * @param lid LiveActivityId 查询
	 *  @param productid 规格di
	 * @return
	 * @throws InterruptedException
	 */
	public List<LiveActivityProduct> selectLiveactivityproduct(Integer lid,String productid) throws InterruptedException {
		Map m = new HashMap<>();
		m.put("lid", lid);
		m.put("pid", productid);
		List<LiveActivityProduct> messagetaske = manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectLiveactivityproduct", m);
		manage.commit();
		return messagetaske;
	}
	public List<Map> selectLivecategory() throws InterruptedException {
		List<Map> messagetaske = manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectLivecategory", null);
		manage.commit();
		return messagetaske;
	}
	public List<Map> selectSystemNotify(Integer liveid) throws InterruptedException {
		Map m = new HashMap<>();
		m.put("liveid", liveid);
		List<Map> messagetaske = manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectSystemNotify", m);
		manage.commit();
		return messagetaske;
	}
	public List<LiveChatMessagePo> selectLivehatMessageByMsgSeq(Long MsgSeq) throws InterruptedException {
		Map m = new HashMap<>();
		m.put("MsgSeq", MsgSeq);
		List<LiveChatMessagePo> messagetaske = manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectLivehatMessageByMsgSeq", m);
		manage.commit();
		return messagetaske;
	}
//	selectLivehatMessageByMsgSeq
	/**
	 * 更新通知创建时间
	 * @param liveid
	 * @param Date
	 * @return
	 */
	public int updateSystemNotifyCreateTime(Integer liveid, Date ctime) {
		Map m = new HashMap<>();
		m.put("liveid", liveid);
		m.put("ctime", ctime);
		int i = manage.update("com.ymttest.database.mapping.LiveRoomMapper.updateSystemNotifyCreateTime", m);
		manage.commit();
		return i;
	}
	//update liveactivityproduct set ActivityStock=#{activityStock} ,SoldStock=#{soldStock}  where productid=#{pid} 
	/**
	 * 修改活动商品的已售数量和库存数量
	 * @param pid
	 * @param activityStock
	 * @param soldStock
	 * @return
	 */
	public int updateLiveactivityByProduct(String pid,Integer activityStock, Integer soldStock) {
		Map m = new HashMap<>();
		m.put("activityStock", activityStock);
		m.put("soldStock", soldStock);
		m.put("pid", pid);
		int i = manage.update("com.ymttest.database.mapping.LiveRoomMapper.updateLiveactivityByProduct", m);
		manage.commit();
		return i;
	}
	/**
	 * 修改活动商品的状态 结束
	 * @param pid
	 * @param status
	 * @return
	 */
	public int updateLiveactivityStatusToEndByProduct(String pid) {
		String end = YMTDateUtil.getFormatTime(YMTDateUtil.getDate(), YMTDateUtil.YMDHMS);
		Map m = new HashMap<>();
		m.put("status", 4);
		m.put("pid", pid);
		m.put("end", end);
		int i = manage.update("com.ymttest.database.mapping.LiveRoomMapper.updateLiveactivityStatusByProduct", m);
		manage.commit();
		return i;
	}
	
	/**
	 * 更新用户最后足迹时间
	 * @param uid
	 * @param utime
	 * @return
	 */
	public int updateLivefootprintUpdateTimeByUid(Integer uid, Date utime) {
		Map m = new HashMap<>();
		m.put("uid", uid);
		m.put("utime", utime);
		int i = manage.update("com.ymttest.database.mapping.LiveRoomMapper.updateLivefootprintUpdateTimeByUid", m);
		manage.commit();
		return i;
	}
	//updateLiveactivityStartTimeByLiveactivityid
	/**
	 * 更新直播秒杀活动开始时间
	 * @param uid
	 * @param utime
	 * @return
	 */
	public int updateLiveactivityStartTimeByLiveactivityid(Integer liveactivityid, Date stime) {
		Map m = new HashMap<>();
		m.put("liveactivityid", liveactivityid);
		m.put("stime", stime);
		int i = manage.update("com.ymttest.database.mapping.LiveRoomMapper.updateLiveactivityStartTimeByLiveactivityid", m);
		manage.commit();
		return i;
	}
	//selectLivenotice
	public List<Map> selectLivenotice(Integer id) throws InterruptedException {
		Map m = new HashMap<>();
		m.put("id", id);
		List<Map> messagetaske = manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectLivenotice", m);
		manage.commit();
		return messagetaske;
	}
	/**
	 * 查询禁言
	 * @param userid
	 * @param state 0禁言 1解禁
	 * @return
	 * @throws InterruptedException
	 */
	public List<SpeakingNotAllowed> selectSpeakingNotAllowed(Integer userid,Integer state) throws InterruptedException {
		Map m = new HashMap<>();
		m.put("userid", userid);
		m.put("state", state);
		List<SpeakingNotAllowed> messagetaske = manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectSpeakingNotAllowed", m);
		manage.commit();
		return messagetaske;
	}
//	@Select("SELECT * FROM model WHERE ModelId=#{id}")
//    List<Model> selectModelById(Map m);
	/**
	 * 查询模特信息
	 * @param id
	 * @return
	 * @throws InterruptedException
	 */
	public List<Model> selectModelById(Integer id) throws InterruptedException {
		Map m = new HashMap<>();
		m.put("id", id);
		List<Model> messagetaske = manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectModelById", m);
		manage.commit();
		return messagetaske;
	}
//    @Select(" SELECT * FROM livemodel WHERE liveid=#{liveid} AND ACTION = 0")
//    List<LiveModel> selectLiveModelByLiveId(Map m);
	/**
	 * 查询直播间模特信息
	 * @param id
	 * @return
	 * @throws InterruptedException
	 */
	public List<LiveModel> selectLiveModelByLiveId(Integer liveid) throws InterruptedException {
		Map m = new HashMap<>();
		m.put("liveid", liveid);
		List<LiveModel> messagetaske = manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectLiveModelByLiveId", m);
		manage.commit();
		return messagetaske;
	}
	/**
	 * 查询直播商品打点信息
	 * @param liveid
	 * @param pid
	 * @return
	 * @throws InterruptedException
	 */
	public List<LiveProductDot> selectLiveproductdot(Integer liveid,String pid) throws InterruptedException {
		Map m = new HashMap<>();
		m.put("liveid", liveid);
		m.put("pid", pid);
		List<LiveProductDot> messagetaske = manage.getSelectResults("com.ymttest.database.mapping.LiveRoomMapper.selectLiveproductdot", m);
		manage.commit();
		return messagetaske;
	}
//    @Delete("DELETE FROM model WHERE  userid=#{userid}")
//    int  deleteModelByUserId(Map m);
	/**
	 * 删除用户模特
	 * @param liveid
	 * @param uid
	 * @return
	 */
	public int deleteModelByUserId(Integer userid) {
		Map m = new HashMap<>();
		m.put("userid", userid);
		int i = manage.delete("com.ymttest.database.mapping.LiveRoomMapper.deleteModelByUserId", m);
		manage.commit();
		return i;
	}
	public static void main(String[] args) throws InterruptedException {
		System.out.println(FormatUtil.beanToGSONString(new LiveRoomWapper().selectLiveproductdot(336819,"p4718568")));
//		System.out.println(FormatUtil.beanToGSONString(new LiveRoomWapper().selectProductvideo("p1646971")));
//		new LiveRoomWapper().updateLiveRoomEndTimeAndUpdateTime(YMTDateUtil.getBeforeOrNextMunite());
	}


}
